package com.haibara.codesubmiteval.chain.userChain;

import com.haibara.codesubmiteval.model.dto.user.UserAddRequest;
import com.haibara.codesubmiteval.model.entity.User;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * 处理默认分数的节点
 *
 * @Author: mengyu
 * @Date: 2025/4/28
 */
@Component
@Order(3)
public class ScoreDefaultValueHandler extends CreateUserDefaultValueHandler {
    @Override
    public void handleDefaultValue(User user, UserAddRequest userAddRequest) {
        Integer score = userAddRequest.getScore();
        user.setScore(Objects.requireNonNullElse(score, 0));
        if (next != null) next.handleDefaultValue(user, userAddRequest);
    }
}
